import Vue from 'vue'
import App from './App'
import store from './store'
import router from './router'
import Vuei18n from 'vue-i18n'
import { sync } from 'vuex-router-sync'
import axios from 'axios'
import 'amfe-flexible'
import defaultSettings from './defaultSettings'
import zh_CN from "ant-design-vue/es/locale-provider/zh_CN";
import './assets/fonts/iconfont.css';
import { Button, Field, Uploader, Dialog, Popup, Toast, Notify, Icon, Picker, Checkbox, List, NumberKeyboard, ImagePreview, CheckboxGroup, Tab, Tabs } from 'vant';
import { Image as VanImage } from 'vant';
import 'vant/lib/index.css';
// 引入echarts
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts
Vue.config.productionTip = false
Vue.use(Vuei18n)
Vue.use(Button)
  .use(Field)
  .use(Uploader)
  .use(Dialog).use(Popup).use(Toast).use(Notify)
  .use(Icon)
  .use(Picker)
  .use(List)
  .use(Checkbox).use(NumberKeyboard).use(ImagePreview).use(VanImage)
  .use(CheckboxGroup)
  .use(Tab).use(Tabs);
const messages = {
  "zh_CN": zh_CN
}
const i18n = new Vuei18n({
  locale: 'zh_CN',  // 语言标识
  messages
})

Vue.prototype.$axios = axios

const on = Vue.prototype.$on
Vue.prototype.$on = function(event, func) {
  let previous = -1
  let newFunc = func
  if (event === 'click') {
    newFunc = function() {
      const now = new Date().getTime()
      if (previous + 500 <= now) {
        func.apply(this, arguments)
        previous = now
      }
    }
  }
  on.call(this, event, newFunc)
}



sync(store, router)

//加载默认设置
store.commit('global/UpdateDefaultSettings', defaultSettings)



new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')
